<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateDeviceRecordsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('device_records', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('device_id')->unsigned()->index();
            $table->string('message_number')->default('0');
            $table->integer('TDS1')->default(0);
            $table->integer('TDS2')->default(0);
            //滤芯提醒处理状态
            $table->integer('dec_status')->default(0);
            //流量提醒处理状态
            $table->boolean('flow_status')->default(0);
            $table->boolean('filter_status')->default(0);
            $table->integer('filter_cnt1')->default(0);
            $table->integer('filter_cnt2')->default(0);
            $table->integer('filter_cnt3')->default(0);
            $table->integer('filter_cnt4')->default(0);
            $table->integer('filter_cnt5')->default(0);
            $table->integer('filter_set1')->default(0);
            $table->integer('filter_set2')->default(0);
            $table->integer('filter_set3')->default(0);
            $table->integer('filter_set4')->default(0);
            $table->integer('filter_set5')->default(0);
            $table->integer('filter1')->default(0);
            $table->integer('filter2')->default(0);
            $table->integer('filter3')->default(0);
            $table->integer('filter4')->default(0);
            $table->integer('filter5')->default(0);
            $table->integer('total_flow')->default(0);
            $table->integer('residual_flow')->default(0);
            $table->timestamps();

            $table->foreign('device_id')
                  ->references('id')
                  ->on('devices')
                  ->onDelete('cascade')
                  ->onUpdate('cascade');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('device_records');
    }
}
